<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker,autocomplete"></t:base>
<div class="easyui-layout" fit="true">
    <div region="center" style="padding:0px;border:0px">
        <t:datagrid name="l0" pagination="true"  title=""  fitColumns="false" onLoadSuccess="doload"  onClick="onselect"  actionUrl="scrwglController.do?sublistDatagrid" idField="id" fit="true" >
            <t:dgCol title="id"  field="id"   hidden="true"    width="120"></t:dgCol>
            <t:dgCol title="fd_stat"  field="fd_stat"   hidden="true"    width="120"></t:dgCol>
            <t:dgCol title="状态" field="gifpath" image="true" style="width:20px; height:20px;"></t:dgCol>
            <%-- <t:dgCol title="任务标识"  field="fd_taskno"    width="100"></t:dgCol>--%>
            <t:dgCol title="频率(秒)"  field="fd_pl"    width="60"></t:dgCol>
            <t:dgCol title="是否启动"  field="fd_autostart"    width="60"></t:dgCol>
            <t:dgCol title="上传备份目录"  field="fd_upmlbak"    width="180"></t:dgCol>
            <t:dgCol title="ftp服务器ip"  field="fd_ftpaddr"    width="120"></t:dgCol>
             <t:dgCol title="ftp端口"  field="fd_ftpport"    width="60"></t:dgCol>
            <t:dgCol title="ftp用户"  field="fd_ftpusr"    width="100"></t:dgCol>
            <t:dgCol title="ftp密码"  field="fd_ftppw"    width="120"></t:dgCol>
            <t:dgCol title="ftp目录"  field="fd_upml"     width="120"></t:dgCol>
            <%-- <t:dgCol title="ftp目录"  field="fd_upml"    width="100"></t:dgCol> --%>
            <t:dgCol title="操作" field="opt" width="60"></t:dgCol>
            <t:dgDelOpt title="删除" url="scrwglController.do?dodel&p=0&id={id}" urlclass="ace_button"  urlfont="fa-trash-o"/>

            <t:dgToolBar title="录入" icon="icon-add" url="scrwglController.do?edit&p=0" funname="add" width="500" height="500"></t:dgToolBar>
            <t:dgToolBar title="编辑" icon="icon-edit" url="scrwglController.do?edit&p=0" funname="update" width="500"></t:dgToolBar>
            <t:dgToolBar title="启动" icon="icon-goright" funname="dorun" ></t:dgToolBar>
            <t:dgToolBar title="停止" icon="icon-exit" funname="dostop" ></t:dgToolBar>
        </t:datagrid>
    </div>

</div>

<script type="text/javascript">
    function onselect(rowData) {

        var selected = $('#l0').datagrid('getSelected');
       // window.parent.tableid = selected.id;
        window.parent.twotableid = selected.id;

        /*
         window.parent.onetableid = selected.id;
         window.parent.rowIndex   = rowIndex;
         if(window.parent.pageSelected==0){
         window.parent.suber.location.replace("/fwq/scrwglController.do?twotitle&keyid="+window.parent.onetableid+"&pageno="+window.parent.pageSelected);
         };*/
    }
    function doload(rowData){
        var selected = $('#l0').datagrid('getSelected');
        if(selected) {
            var ntotlength = rowData.rows.length;
            if(ntotlength < 1) {
                window.parent.twotableid = "";
            }
        } else {
            var ntotlength = rowData.rows.length;
            if(ntotlength > 0) {
                $('#l0').datagrid('selectRow',0);
                var selected = $('#l0').datagrid('getSelected');
                window.parent.twotableid = selected.id;
            } else {

                window.parent.twotableid = "";

            }
        }
    }
    //启动任务
    function dorun(){

        var selected = $('#l0').datagrid('getSelected');

       if(selected != null && selected != ''){


            if(selected.fd_stat=="1"||selected.fd_stat=="2"){
                alert("只有处于停止状态且已发布的任务才能启动！");
                return;
            }
           doSubmit("<%=request.getContextPath()%>/scrwglController.do?dorun&id="+selected.fd_taskno,"l0");
           rowid = '';

        }
    }

    //停止任务
    function dostop(){
       var selected = $('#l0').datagrid('getSelected');
        if(selected != null && selected != ''){

            if(selected.fd_stat!="1"){
                alert("只有处于活动状态的任务才能停止！");
                return;
            }
            doSubmit("<%=request.getContextPath()%>/scrwglController.do?dostop&id="+selected.fd_taskno,"l0");
            rowid = '';
        }
    }
</script>